package unmsm.eapisw.taller.srh_servicio.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import unmsm.eapisw.taller.srh_persistencia.dao.IAdministradorDAO;
import unmsm.eapisw.taller.srh_persistencia.modelo.Administrador;
import unmsm.eapisw.taller.srh_servicio.IAdministradorServicio;

@Transactional(readOnly=true)
@Service(value="admService")
public class AdministradorServicio implements IAdministradorServicio{
	// UserDAO is injected...
	@Autowired
	IAdministradorDAO admDAO;

	//@Transactional(readOnly=true)
	public void addAdministrador(Administrador adm) {
		
		
	}

	public void deleteAdministrador(Administrador adm) {
		// TODO Auto-generated method stub
		
	}

	public void updateAdministrador(Administrador adm) {
		// TODO Auto-generated method stub
		
	}

	public IAdministradorDAO getAdmDAO() {
		return admDAO;
	}

	public void setAdmDAO(IAdministradorDAO admDAO) {
		this.admDAO = admDAO;
	}

	public Administrador getAdministratorById(String usuario, String pass) {

		
		Administrador u = getAdmDAO().getAdministradorById(usuario);
		if(u!=null){
			 if(u.getPassword().equals(pass)){
		        	u.setPassword(null);
		        	return u;
		     }else{

		    	 return null;
		     }
		}
       
        
        return null;

	}

	public List<Administrador> getAdministradores() {
        return getAdmDAO().getAdministrador();
	}

}
